/*
 *  Copyright 2020-2021 Li Fei
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.pengshun.modules.api.coal.controller;

import com.pengshun.modules.api.coal.domain.Coal;
import com.pengshun.modules.api.coal.para.CoalParam;
import com.pengshun.modules.api.coal.para.MapPara;
import com.pengshun.modules.api.coal.para.PagePara;
import com.pengshun.modules.api.coal.service.CoalMineService;
import com.pengshun.modules.api.coal.validator.Second;
import com.pengshun.modules.common.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * @author lifei
 * @date 2020-11-04
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "矿口管理")
@RequestMapping("/api/mineMouth")
public class CoalMineController     {

    private final CoalMineService mineMouthService;


    @ApiOperation("查询矿口信息列表")
    @GetMapping(value = "/info")
    public BaseResult coalMineList(@Valid PagePara para) throws Exception {
        BaseResult res = mineMouthService.selectPageList(para);
        return res;
    }

    @ApiOperation("查询矿口详情")
    @ApiImplicitParam(name = "mineMouthId", value = "矿口id", dataType = "int", required = true, paramType = "query")
    @GetMapping(value = "/detil")
    public BaseResult selectCoalMineDetil(@ApiIgnore @Validated(value = {Second.class}) CoalParam para) throws Exception {
        BaseResult res = mineMouthService.selectCoalMineDetil(para.getMineMouthId());
        return res;
    }


    @ApiOperation(value = "查找煤款地图导航", notes = " ")
    @GetMapping(value = "/info/map")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "longitude", value = "经度", dataType = "double", required = true, paramType = "query"),
            @ApiImplicitParam(name = "latitude", value = "纬度", dataType = "double", required = true, paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "string",   paramType = "query"),
    })
    public BaseResult selectAllMerchantMap(@ApiIgnore   MapPara para) throws Exception {
        BaseResult res = mineMouthService.selectAllMerchantMap(para);
        return res;
    }
    @ApiOperation(value = "所有地图导航", notes = " ")
    @GetMapping(value = "/info/all")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "longitude", value = "经度", dataType = "double", required = true, paramType = "query"),
            @ApiImplicitParam(name = "latitude", value = "纬度", dataType = "double", required = true, paramType = "query"),
            @ApiImplicitParam(name = "name", value = "名称", dataType = "string",   paramType = "query"),
    })
    public BaseResult selectAlltMap(@ApiIgnore @Validated(value = {Second.class}) MapPara para) throws Exception {
        BaseResult res = mineMouthService.selectAlltMap(para);
        return res;
    }

    @ApiOperation("查询所有煤矿")
    @GetMapping(value = "/all")
    public BaseResult allCoalMineList( )   {
        BaseResult res = mineMouthService.allCoalMineList();
        return res;
    }

    @ApiOperation("查询煤矿下的煤种")
    @GetMapping(value = "/coal-category")
    @ApiImplicitParam(name = "mineMouthId", value = "煤矿id", dataType = "int", required = true, paramType = "query")
    public BaseResult coalCategory(Long mineMouthId)   {
        BaseResult res = mineMouthService.coalCategory(mineMouthId);
        return res;
    }
    @ApiOperation("查询煤种下的煤炭")
    @GetMapping(value = "/coals")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineMouthId", value = "煤矿id", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "coalCategoryId", value = "煤种id", dataType = "int", required = true, paramType = "query")
    })

    public BaseResult coals(@ApiIgnore Coal coal)   {
        BaseResult res = mineMouthService.coals(coal);
        return res;
    }
}